package git.soulbgm.controller;

import git.soulbgm.common.map.SendDataMap;
import git.soulbgm.pojo.SendInfo;
import git.soulbgm.utils.LogUtil;
import org.springframework.web.bind.annotation.*;

/**
 * 发送数据控制器
 *
 * @author SoulBGM
 * @date 2024/01/08
 */
@RestController
public class SendDataController {

    private static final LogUtil LOG = new LogUtil(SendDataMap.class);

    @PostMapping("put")
    public String put(@RequestBody SendInfo info) {
        SendDataMap.put(info);
        LOG.info("添加数据, PID:{}", info.getPacketId());
        return "success";
    }

    @DeleteMapping("remove")
    public String remove(@RequestBody SendInfo info) {
        SendDataMap.remove(info.getPacketId(), info.getTargetId());
        LOG.info("删除数据, PID:{}, TID:{}", info.getPacketId(), info.getTargetId());
        return "success";
    }

}
